# routers/action_item.py
import logging
from fastapi import APIRouter, Depends
from schema_base import PageInationResult
from http_base import unified_resp
from ..schemas.action_item import (
    ActionItemListIn, ActionItemDetailIn, ActionItemAddIn, ActionItemEditIn, ActionItemDelIn, ActionItemOut
)
from ..service.ai.action_item import IActionItemService

logger = logging.getLogger(__name__)
router = APIRouter(prefix="/action_items")


@router.post("/list", response_model=PageInationResult[ActionItemOut], summary="行动项列表")
@unified_resp
async def action_item_list(list_in: ActionItemListIn, svc: IActionItemService = Depends()):
    return await svc.list(list_in)


@router.get("/detail", summary="行动项详情")
@unified_resp
async def action_item_detail(detail_in: ActionItemDetailIn = Depends(), svc: IActionItemService = Depends()):
    return await svc.detail(detail_in.id)


@router.post("/add", summary="新增行动项")
@unified_resp
async def action_item_add(add_in: ActionItemAddIn, svc: IActionItemService = Depends()):
    return await svc.add(add_in)


@router.post("/edit", summary="编辑行动项")
@unified_resp
async def action_item_edit(edit_in: ActionItemEditIn, svc: IActionItemService = Depends()):
    return await svc.edit(edit_in)


@router.post("/del", summary="删除行动项")
@unified_resp
async def action_item_del(del_in: ActionItemDelIn, svc: IActionItemService = Depends()):
    return await svc.delete(del_in.id)
